//============================================================================
// Name        : falcon.cpp
// Author      : zwx
// Version     :
// Copyright   : copyright zwx
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string.h>
#include "./Processor/Processor.h"
using namespace std;

int get_mode(char *s);
int get_model(char *s);
int get_zone(char *s);

int main(int argc, char** argv) {
	/*
	 *  ./falcon [-r|-s] <configure_path> --[boolean|cosine|okapi|my_model] <zone>
	 */
	if (argc < 4) {
		cout << "need more arguments" << endl;
		return -1;
	}

	int mode;
	int model;
	int zone;

	mode = get_mode("-s");	//0 for batch mode, 1 for online mode
	model = get_model("--zwx");	//0 for boolean, 1 for cosine, 2 for okapi, 3 for custom
	zone = get_zone("--title");	//0 for title, 1 for narr, 2 for title+narr

	if (mode < 0 || model <0 || zone < 0){
		cout<<"arguments format mistake"<<endl;
		return -1;
	}

	Processor* prc = Processor::getInstance();
	prc->process(argv[2], argv[3], mode, model, zone);

	cout<<"APPLICATION EXIT"<<endl;
	return 0;
}

int get_zone(char* s) {
	if (strcmp(s, "--title") == 0) {
		return 0;
	}
	if (strcmp(s, "--narr") == 0) {
		return 1;
	}
	if (strcmp(s, "--title+narr") == 0) {
		return 2;
	}
	return -1;
}

int get_model(char* s) {
	if (strcmp(s, "--boolean") == 0) {
		return 0;
	}
	if (strcmp(s, "--cosine") == 0) {
		return 1;
	}
	if (strcmp(s, "--okapi") == 0) {
		return 2;
	}
	if (strcmp(s, "--zwx") == 0) {
		return 3;
	}
	return -1;
}

int get_mode(char* s) {
	if (strcmp(s, "-r") == 0) {
		return 0;
	}
	if (strcmp(s, "-s") == 0) {
		return 1;
	}
	return -1;
}
